define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'lemon.module/index',
        add_url: 'lemon.module/add',
        edit_url: 'lemon.module/edit',
        delete_url: 'lemon.module/delete',
        modify_url: 'lemon.module/modify'
    };

    var Controller = {

        index: function () {
            ea.table.render({
                init: init,
                search: false,
                page: false,
                toolbar: ['refresh',
                    [{
                        text: '添加',
                        url: init.add_url,
                        method: 'open',
                        auth: 'add',
                        class: 'layui-btn layui-btn-normal layui-btn-sm',
                        icon: 'fa fa-plus ',
                        extend: 'data-full="true"',
                    }
                    ]],
                cols: [[
                    {field: 'title', width: 240, align: 'left', title: '模块名称'},
                    {field: 'name', width: 150, title: '标识符 <i class="table-edit-tips color-red">*</i>', edit: 'text'},
                    {field: 'ps', minWidth: 200, align: 'left', title: '描述'},
                    {field: 'versions', width: 150, align: 'left', title: '版本号'},
                    {field: 'update_time', width: 150, title: '更新时间', search: 'range'},
                    {
                        width: 250,
                        title: '操作',
                        templet: ea.table.tool,
                        operat: [
                            [{
                                text: '编辑',
                                url: init.edit_url,
                                method: 'open',
                                auth: 'edit',
                                class: 'layui-btn layui-btn-xs layui-btn-success',
                            }, {
                                text: '发布',
                                url: init.stock_url,
                                method: 'open',
                                auth: 'stock',
                                class: 'layui-btn layui-btn-xs layui-btn-normal',
                            }],
                            'delete']
                    }
                ]],
            });

            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        }
    };
    return Controller;
});